<%@ page import="org.biojava.services.das.dao.RegistryUser" %>
<%@ page import="org.biojava.services.das.registry.UserManager" %>
<%@ page import="org.biojava.services.das.dao.Role" %>
<%@ page import="java.util.Date" %>
<jsp:directive.page import="org.springframework.beans.factory.BeanFactory"/>
<jsp:directive.page import="org.springframework.context.support.ClassPathXmlApplicationContext"/>



<% String title="list all users";
   String header=title;
%>

<%@ include file="sangerheader.jsp" %>
<%
 if  ( ! isAdmin ) {
	session.setAttribute("message","only administrators can view the showUsers.jsp page");
	response.sendRedirect("login.jsp");	
	return;
} else { 
%>




<div id="main">

<h2>Currently registered users in registry</h2>

<%@ include file="sangertablestart.jsp" %>

<tr id="row0">
<td>id</td>
<td>email</td>
<td>email</td>
<td>role</td>
</tr>
<%

BeanFactory ctx=(new ClassPathXmlApplicationContext("SpringDAO.xml"));
UserManager manager=(UserManager)ctx.getBean("userManager");
	
	RegistryUser[] users = manager.getAllUsers();
	int count = -1;	
	for (int u=0; u < users.length ; u++){
		RegistryUser tmp = users[u];
		count++;		
		%>
		
<% if (count % 2 != 0) {
%>
<tr id="row1" valign="top">
	<%
	} else {
	%>

<tr id="row2" valign="top">
<%} %>		
<td><%=tmp.getUserID() %></td>
<td><%=tmp.getEmail() %></td>
<td><a href="mailto:<%=tmp.getEmail()%>"><%=tmp.getEmail() %></a></td>
<td><%=tmp.getRole() %></td>
</tr>
		<% 
	}
	
	
	%>
<%@ include file="sangertableend.jsp" %>
	
<%} %>
<%@ include file="sangerfooter.jsp" %>
